package day05;
/**
 * 方法的演示---参数
 */
public class MethodDemo1 {
    public static void main(String[] args) {
        /*
        say(); //调用say()方法
        System.out.println("----------------------");

        //sayHi(); //编译错误，有参则必须传参
        //sayHi(250); //编译错误，参数类型必须匹配
        sayHi("zhangsan"); //String name="zhangsan"-----------------实参
        sayHi("lisi"); //String name="lisi"-------------------------实参
        System.out.println("----------------------");

        sayHello("zhangsan",25); //String name="zhangsan",int age=25-----实参
        sayHello("lisi",66); //String name="lisi",int age=66-------------实参
        */

        say(); //自动绑定无参say
        say("zhangsan"); //自动绑定String参的say
        say("lisi",25); //自动绑定String+int参的say
        //say(3.456); //编译错误，没有double参的say
    }

    //无参无返回值
    public static void say(){
        System.out.println("大家好，我叫WKJ，今年40岁了");
    }
    //有参无返回值
    public static void say(String name){ //---------------------------形参
        System.out.println("大家好，我叫"+name+"，今年40岁了");
    }
    //有参无返回值
    public static void say(String name,int age){ //----------------形参
        if(age>=60){ //在某种特定条件下，提前结束方法
            return; //结束方法
        }
        System.out.println("大家好，我叫"+name+"，今年"+age+"岁了");
    }

    public static void say(int age){} //正确的重载
    public static void say(int age,String name){} //正确的重载
    //public static int say(){ return 1; } //编译错误，重载与返回值类型无关
    //public static void say(String address){} //编译错误，重载与参数名称无关

}















